/**
 * Created by IntelliJ IDEA.
 * User: mabo
 * Date: 2009-8-11
 * Time: 20:56:28
 * To change this template use File | Settings | File Templates.
 */


var tree = new Ext.tree.TreePanel({
    containerScroll: true,
    region:'center',
    rootVisible:false,
    lines:false,
    useArrows:true,
    header:false,
    root:new Ext.tree.AsyncTreeNode({
        text:"根节点",
        id:"root",
        children:[
            {
                text:"数据管理",
                id:"数据管理",
                expanded:true,
                children:[
                    {
                        text:"数据表管理",
                        id:"数据表管理",
                        leaf:true,
                        listeners:{
                            "click":function(n, e) {
                                new Faceye.load(basePath + "jscore/test/test.js");//动态载入JS文件
                                addTabPanel(this, path + "/sys/bottom_login.html");
                                updateSouth("");
                            }
                        }
                    },
                    {
                        text:"数据集管理",
                        id:"数据集管理",
                        leaf:true
                    }
                ]
            },
            {
                text:"程序流",
                id:"程序流",
                expanded:true,
                children:[
                    {
                        text:"流程管理",
                        id:"流程管理",
                        leaf:true,
                        listeners:{
                            "click":function(n, e) {
                                new Faceye.load(basePath + "jscore/test/test.js");//动态载入JS文件
                                addTabPanel(this, path + "/sys/bottom_login.html");
                                updateSouth("");
                            }
                        }
                    }
                ]
            },
            {
                text:"模板管理",
                id:"模板管理",
                expanded:true,
                children:[
                    {
                        text:"添加模板",
                        id:"添加模板",
                        leaf:true
                    },
                    {
                        text:"选定数据集",
                        id:"选定数据集",
                        leaf:true
                    }
                ]
            },
            {
                text:"简历辅助发送工具",
                id:"简历辅助发送工具",
                expanded:true,
                children:[
                    {
                        text:"设置收集地址",
                        id:"设置收集地址",
                        leaf:true,
                        listeners:{
                            "click":function(n, e) {
                                addTabPanel(this, path + "/hr/hrconfig.x?op=go&go=list");
                                updateSouth("")
                            }
                        }
                    },
                    {
                        text:"浏览招聘信息",
                        id:"浏览招聘信息",
                        leaf:true,
                        listeners:{
                            "click":function(n, e) {
                                addTabPanel(this, path + "/hr/zhaopin.x?op=go&go=zhaopin_list");
                                updateSouth("")
                            }
                        }
                    }
                ]
            },
            {
                text:"ExtJs帮助",
                id:"ExtJs帮助",
                expanded:true,
                children:[
                    {
                        text:"实例",
                        id:"实例",
                        leaf:true,
                        listeners:{
                            "click":function(n, e) {
                                addTabPanel(this, path + "/ext/examples");
                                updateSouth("")
                            }
                        }
                    },
                    {
                        text:"API",
                        id:"API",
                        leaf:true,
                        listeners:{
                            "click":function(n, e) {
                                addTabPanel(this, path + "/ext/docs");
                                updateSouth("")
                            }
                        }
                    }
                ]
            }
        ]
    })
});

//向tabPanel内，添加一标签页
var addTabPanel = function (obj, uri) {
    if (!tabPanel.getComponent("tabPanel_" + obj.id)) {//判断是否加载过此标签页
        tabPanel.add({
            title:obj.text,
            id:"tabPanel_" + obj.id,
            closable:true,
            html: '<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="'
                    + uri + '"></iframe>'
            /*autoLoad:{//ajax异步载入
             url:uri,
             text:"载入中。。。"
             }*/
        });
    }
    tabPanel.setActiveTab("tabPanel_" + obj.id);
}

var updateSouth = function(str) {
    Ext.get("south_panel_div").dom.innerHTML = str;
}

var tabPanel = new Ext.TabPanel({
    id:"main_tabPanel",
    region:'center',
    autoScroll:true,
    margins:'35 5 5 0',
    activeTab:0,
    frame:true,
    items:[
        {
            title:"欢迎",
            id:"欢迎",
            html:"<div> 欢迎，欢迎，热烈欢迎 </div>"
            /*autoLoad:{
             url:"/jscore/test/test.jsp",
             loadScripts:true,
             text:"载入中。。。"
             },*/
        }
    ]
});


//Ext载入初始
Ext.onReady(function() {
    var viewport = new Ext.Viewport({
        layout:'border',
        items:[
            {
                region:'west',
                id:'west-panel',
                title:'功能菜单',
                split:true,
                width: 200,
                minSize: 175,
                maxSize: 400,
                collapsible: true,
                margins:'35 0 5 5',
                cmargins:'35 5 5 5',
                layout:"border",
                defaults: {
                    collapsible: true,
                    split: true
                },
                items: [
                    {
                        title: '功能说明',
                        region: 'south',
                        height: 150,
                        minSize: 75,
                        maxSize: 250,
                        cmargins: '5 0 0 0',
                        layout:"fit",
                        items:[
                            new Ext.Panel({
                                html:"<div id='south_panel_div'><div>",
                                autoScroll:true
                            })
                        ]
                    },
                    tree
                ]
            },
            tabPanel
        ]
    });


    /*new Faceye.load(basePath + "jscore/test/test.js");
     var up = Ext.get("欢迎").getUpdater();
     up.update({
     url:basePath + "jscore/test/test.jsp",
     text:"载入中。。。"
     });*/

});